#include "MemoryPool.hpp"
#include <vector>

int main() {
    try {
        // 创建块大小为128字节的内存池
        MemoryPool pool(128);
        pool.printStatus();

        std::vector<void*> blocks;
        
        // 分配10个块
        for (int i = 0; i < 10; ++i) {
            blocks.push_back(pool.allocate());
        }
        pool.printStatus();

        // 释放部分块
        pool.deallocate(blocks[5]);
        pool.deallocate(blocks[3]);
        blocks[3] = blocks[5] = nullptr;

        pool.printStatus();
        
        // 内存池会在析构时自动检测泄漏
    }
    catch (const std::exception& e) {
        std::cerr << "Error: " << e.what() << "\n";
    }
    return 0;
}